package com.nervenets.web.hibernate.domain;

import com.nervenets.web.enumeration.Gender;
import com.nervenets.web.hibernate.DomainObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 用户
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "users", indexes = {
        @javax.persistence.Index(name = "_idx_user_open_id", columnList = "openId"),
        @javax.persistence.Index(name = "_idx_user_union_id", columnList = "unionId")
})
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User extends DomainObject {
    private String openId;
    private String unionId;
    private String name;
    private String avatar;
    @Column(columnDefinition = "tinyint")
    private Gender gender = Gender.female;
    private String mobile;
    private boolean enable;
    private int lastLoginTime;

    public User(String openId, String unionId, String name) {
        this.openId = openId;
        this.unionId = unionId;
        this.name = name;
    }
}
